<template>
  <div>
    <el-table
    :data=userList
    border
    stripe
    style="width: 100%">

      <el-table-column
      prop="id"
      label="ID"
      width="180">
      </el-table-column>

      <el-table-column
        prop="username"
        label="姓名"
        width="180">
      </el-table-column>

      <el-table-column
        prop="password"
        label="密码"
        width="180">
      </el-table-column>

      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>

      <el-table-column
        prop="group.name"
        label="组名"
        width="180">
      </el-table-column>
    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="this.queryInfo.pageNum"
        :page-sizes="[5,10,15]"
        :page-size="5"
        layout="total, sizes, prev, pager, next, jumper"
        :total="this.totalNumber">
    </el-pagination>
  </div>
</template>



<script>
export default {
  created () {
    this.getUserList();
  },

  data() {
    return{
      queryInfo: {
        pageNum: 0,
        pageSize: 5
      },
      userList: [],
      totalNumber: 0
    }
  },
  methods: {
    async getUserList(){
      // eslint-disable-next-line no-unused-vars
      const {data:res} = await this.$http.post("/user/findAll/"+this.queryInfo.pageNum+"/"+this.queryInfo.pageSize);
      this.userList = res.userList;
      this.totalNumber = res.number;

    },
    handleSizeChange(newSize){
      this.queryInfo.pageSize = newSize;
      this.getUserList();
    },
    handleCurrentChange(newNum){
      this.queryInfo.pageNum=newNum;
      this.getUserList();
    },

  }

}
</script>


<style scoped>

</style>
